Page({
  data: {
    userInfo: {},
    playModes: [
      { name: '中式九球', icon: '/assets/mode-9ball.png', desc: '标准九球玩法' },
      { name: '美式九球', icon: '/assets/mode-us9.png', desc: '美式九球玩法' },
      { name: '十六彩', icon: '/assets/mode-16color.png', desc: '十六彩玩法' }
    ],
    currentMode: '中式九球'
  },
  onGetUserInfo(e) {
    this.setData({ userInfo: e.detail.userInfo });
  },
  onModeChange(e) {
    this.setData({ currentMode: e.currentTarget.dataset.mode });
  },
  onCreateRoom() {
    wx.navigateTo({ url: `/pages/room-create/index?mode=${this.data.currentMode}` });
  },
  onJoinRoom() {
    wx.navigateTo({ url: '/pages/room-join/index' });
  },
  onViewHistory() {
    wx.navigateTo({ url: '/pages/history/index' });
  },
  onViewRule() {
    wx.navigateTo({ url: '/pages/rule/index' });
  }
});
